<%@ page language="java" pageEncoding="UTF-8" %>
<%@ include file="../common/tags.jsp" %>

<!DOCTYPE html>
<html>
<head lang="en">
    <%@include file="../common/assets.jsp" %>
</head>
<body>
<!-- header -->
<%@include file="../common/header.jsp" %>

<!-- main start -->
<div class="am-cf admin-main">
    <!-- sidebar start -->
    <%@include file="../common/menu.jsp" %>
    <!-- sidebar end -->
    <!-- content start -->
    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf">
                <strong class="am-text-primary am-text-lg">市场</strong> /
                <small>推广</small>
            </div>
        </div>
        <%--合伙人邀请链接--%>
        <div class="am-g" style="margin-bottom: 30px">
            <div class="am-u-sm-12 am-u-md-12">
                <%--合伙人推广链接--%>
                <div class="am-input-group am-show-lg">
                    <span class="am-input-group-label">合伙人邀请链接</span>
                    <input type="text" class="am-form-field" id="partner_url" value="${partnerUrl}"
                            readonly="readonly"/>
                    <span class="am-input-group-btn">
                        <button class="am-btn am-btn-primary" id="copy_partner_url"
                                data-am-popover="{theme: 'primary', content: '你的邀请链接已经复制到剪贴板^-^'}">复制</button>
                    </span>
                </div>
                <div class="am-show-sm-only">
                    <h6>合伙人邀请链接</h6>
                </div>
                <div class="am-input-group am-show-sm-only">
                    ${partnerUrl}
                </div>
                <%--合伙人二维码--%>
                <div class="am-u-sm-12 am-u-md-12" style="margin-top: 15px">
                    <div id="partner_QRCode" class="am-text-center"></div>
                </div>
            </div>
        </div>
        <%--分割线--%>
        <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>

        <%--商家推广链接--%>
        <div class="am-g" style="margin-bottom: 30px">
            <div class="am-u-sm-12 am-u-md-12">
                <div class="am-input-group am-show-lg">
                    <span class="am-input-group-label">商家邀请链接</span>
                    <input type="text" class="am-form-field" id="business_url" value="${businessUrl}"
                            readonly="readonly"/>
                    <span class="am-input-group-btn">
                        <button class="am-btn am-btn-primary" id="copy_business_url"
                                data-am-popover="{theme: 'primary', content: '你的邀请链接已经复制到剪贴板^-^'}">复制</button>
                    </span>
                </div>
                <div class="am-show-sm-only">
                    <h6>商家邀请链接</h6>
                </div>
                <div class="am-input-group am-show-sm-only">
                    ${businessUrl}
                </div>
                <%--商家推广二维码--%>
                <div class="am-u-sm-12 am-u-md-12" style="margin-top: 15px">
                    <div id="business_QRCode" class="am-text-center"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- main end -->

<!-- foot -->
<%@include file="../common/footer.jsp" %>

<script type="text/javascript">
    $(function () {

        makeCode($('#partner_QRCode'), '${partnerUrl}');
        makeCode($('#business_QRCode'), '${businessUrl}');

        $('#copy_partner_url').on('click', function () {
            $('#partner_url').select();
            document.execCommand("Copy"); // 执行浏览器复制命令
            setInterval(function () {
                $('input[name=copy_partner_url]').popover('close');
            }, 2000);

        });
        $("#copy_business_url").on('click', function () {
            $('#business_url').select();
            document.execCommand("Copy"); // 执行浏览器复制命令
            setInterval(function () {
                $("#copy_business_url").popover('close');
            }, 2000);
        });

        function makeCode(target, text) {
            target.empty().qrcode(text);
        }
    });

</script>
</body>
</html>